package com.team1.system.librarycredit.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.team1.common.annotation.Log;
import com.team1.common.core.controller.BaseController;
import com.team1.common.core.domain.AjaxResult;
import com.team1.common.enums.BusinessType;
import com.team1.system.librarycredit.domain.LibraryCredit;
import com.team1.system.librarycredit.service.ILibraryCreditService;
import com.team1.common.utils.poi.ExcelUtil;
import com.team1.common.core.page.TableDataInfo;

/**
 * 信用度信息管理Controller
 * 
 * @author hyy
 * @date 2023-04-09
 */
@RestController
@RequestMapping("/librarysystem/librarycredit")
public class LibraryCreditController extends BaseController
{
    @Autowired
    private ILibraryCreditService libraryCreditService;

    /**
     * 查询信用度信息管理列表
     */
    @PreAuthorize("@ss.hasPermi('librarysystem:librarycredit:list')")
    @GetMapping("/list")
    public TableDataInfo list(LibraryCredit libraryCredit)
    {
        startPage();
        List<LibraryCredit> list = libraryCreditService.selectLibraryCreditList(libraryCredit);
        return getDataTable(list);
    }

    /**
     * 导出信用度信息管理列表
     */
    @PreAuthorize("@ss.hasPermi('librarysystem:librarycredit:export')")
    @Log(title = "信用度信息管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LibraryCredit libraryCredit)
    {
        List<LibraryCredit> list = libraryCreditService.selectLibraryCreditList(libraryCredit);
        ExcelUtil<LibraryCredit> util = new ExcelUtil<LibraryCredit>(LibraryCredit.class);
        util.exportExcel(response, list, "信用度信息管理数据");
    }

    /**
     * 获取信用度信息管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('librarysystem:librarycredit:query')")
    @GetMapping(value = "/{creditId}")
    public AjaxResult getInfo(@PathVariable("creditId") String creditId)
    {
        return success(libraryCreditService.selectLibraryCreditByCreditId(creditId));
    }

    /**
     * 新增信用度信息管理
     */
    @PreAuthorize("@ss.hasPermi('librarysystem:librarycredit:add')")
    @Log(title = "信用度信息管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LibraryCredit libraryCredit)
    {
        return toAjax(libraryCreditService.insertLibraryCredit(libraryCredit));
    }

    /**
     * 修改信用度信息管理
     */
    @PreAuthorize("@ss.hasPermi('librarysystem:librarycredit:edit')")
    @Log(title = "信用度信息管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LibraryCredit libraryCredit)
    {
        return toAjax(libraryCreditService.updateLibraryCredit(libraryCredit));
    }

    /**
     * 删除信用度信息管理
     */
    @PreAuthorize("@ss.hasPermi('librarysystem:librarycredit:remove')")
    @Log(title = "信用度信息管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{creditIds}")
    public AjaxResult remove(@PathVariable String[] creditIds)
    {
        return toAjax(libraryCreditService.deleteLibraryCreditByCreditIds(creditIds));
    }
}
